﻿<?xml version="1.0" encoding="utf-8" ?>

<sqlMap namespace="WorkflowProcess" xmlns="http://ibatis.apache.org/mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
  
  <resultMaps>
    <resultMap id="ActivityResult" class="Activity">
      <result property="ProcessId" column="ProcessId" />
      <result property="ProcessName" column="ProcessName" />
      <result property="ActivityId" column="ActivityId" />
      <result property="Type" column="Type" />
      <result property="Description" column="Description" />
      <result property="ReferenceActivity" column="ReferenceActivity" />
      <result property="Name" column="Name" />
      <result property="Status" column="Status" />
      <result property="Owner" column="Owner" />
      <result property="CatchType" column="CatchType" />
      <result property="NrExecuted" column="NR_EXECUTED" />
      <result property="Grants" column="GRANTS" />
      <result property="Behaviour" column="BEHAVIOUR" />
      <result property="Log" column="LOG" />
      <result property="Logs" column="LOGS" />
      <result property="Reports" column="REPORTS" />
    </resultMap>
  </resultMaps>

  <statements>

    <select id="SelectAllActivities" resultMap="ActivityResult">
      SELECT * from BAM_Activity order by processid, activityid;
    </select>

    <select id="dynamicGetActivityList" parameterClass="Activity" resultMap="ActivityResult" >
      SELECT * from BAM_Activity
      <dynamic prepend="WHERE">
        <isGreaterThan prepend="AND" property="ProcessId" compareValue="0">
          ( ProcessId = #ProcessId# )
        </isGreaterThan>
        <isNotNull prepend="AND" property="ActivityId">
          ActivityId=#ActivityId#
        </isNotNull>
        <isNotNull prepend="AND" property="ProcessName">
          ProcessName=#ProcessName#
        </isNotNull>
        <isEqual prepend="AND" property="Status" compareValue="NotCompleted">
          (Status='RUNNING' OR Status='MANUAL' OR Status='ERROR')
        </isEqual>
      </dynamic>
      order by processid, activityid;
    </select>
  </statements>

</sqlMap>

